#include "N1Lock.h"


N1NAME_DEF(N1Lock)

#ifdef WINDOWS
N1Lock::N1Lock()
{
    InitializeCriticalSection( &cs );
}

N1Lock::N1Lock(uint32 spin)
{
    InitializeCriticalSectionAndSpinCount(&cs, spin);
}

N1Lock::~N1Lock() 
{
    DeleteCriticalSection(&cs);
}

void N1Lock::lock() 
{
    EnterCriticalSection(&cs);
}

void N1Lock::unlock()
{
    LeaveCriticalSection(&cs);
}
#endif

#ifndef WINDOWS
N1Lock::N1Lock()
{
    pthread_mutex_init( &m_mutex, NULL );
}

N1Lock::N1Lock(uint32 spin)
{
    pthread_mutex_init( &m_mutex, NULL );
}

N1Lock::~N1Lock() 
{
    pthread_mutex_destroy( &m_mutex );
}

void N1Lock::lock() 
{
    pthread_mutex_lock( &m_mutex );
}

void N1Lock::unlock()
{
    pthread_mutex_unlock( &m_mutex );
}
#endif

